unit untCons;

interface

uses
  Windows, SysUtils, Classes, Graphics;

procedure SetConsole;
procedure ShowConsole;
procedure WriteConsole(Text: String);
procedure ClearConsole;
procedure FreeConsole;

var
  ConsShow: Boolean;
  ConsText: TStringList;
  Cons: TBitmap;

const
  CONSOLE_HEIGHT = 200;

implementation

uses untMain, untMap;

procedure SetConsole;
begin
  Cons:=TBitmap.Create;
  Cons.Height:=CONSOLE_HEIGHT;
  Cons.Width:=XRES;
  Cons.Canvas.Brush.Color:=RGB(140, 140, 140);
  Cons.Canvas.FillRect(Rect(0, 0, XRES, CONSOLE_HEIGHT));
  ConsText:=TStringList.Create;
  Cons.Canvas.Font.Name:='Courier New';
end;

procedure ShowConsole;
var
  i: Integer;
begin
  Cons.Canvas.FillRect(Rect(0, 0, XRES, CONSOLE_HEIGHT));
  for i:=ConsText.Count-1 downto 0 do
  begin
    Cons.Canvas.TextOut(0, CONSOLE_HEIGHT-(i+1)*(Cons.Canvas.TextHeight(ConsText.Strings[i])+3), ConsText.Strings[i]);
  end;
  BitBlt(Tiles.Canvas.Handle, 0, 0, XRES, CONSOLE_HEIGHT, Cons.Canvas.Handle, 0, 0, SRCPAINT);
end;

procedure WriteConsole(Text: String);
begin
  if ConsText.Count=12 then ConsText.Delete(0);
  ConsText.Insert(0, Text);
end;

procedure ClearConsole;
begin
  ConsText.Clear;
end;

procedure FreeConsole;
begin
  Cons.Free;
  ConsText.Free;
end;

end.
 